package com.situ.team5.kzq.recruit.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.situ.team5.kzq.recruit.dao.EngageResumeDAO;
import com.situ.team5.kzq.recruit.service.EngageResumeService;
import com.situ.team5.kzq.recruit.service.MsService;
import com.situ.team5.kzq.recruit.service.MsServiceImpl;
import com.situ.team5.kzq.recruit.service.SalaryGrantDetailsService;
import com.situ.team5.pojo.EngageInterview;
import com.situ.team5.pojo.EngageResume;
import com.situ.team5.util.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

@Controller
public class MsController extends BaseController {
    @Autowired
    EngageResumeService edao;
    @Autowired
    SalaryGrantDetailsService dao;
    @Autowired
    MsService mdao;
//面试管理有效简历查询
    @RequestMapping("yxjlSelect")
    public String yxjlSelect(Map map, @RequestParam(defaultValue = "1",required = false) Integer startPage,
                             @RequestParam(defaultValue = "5",required = false) Integer PageSize){

        PageHelper.startPage(startPage, PageSize ); //使用分页插件
        List<Map> yxjl=mdao.yxjlSelectAll();
        PageInfo pageInfo=new PageInfo(yxjl, 5); //保存分页信息
        map.put("pageInfo", pageInfo);
        map.put("yxjl", yxjl);
        return"/page/recruit/interview/interview-list.html";

    }

//登记
    @RequestMapping("interview_register")
    public String interview_register(int id,Map map){
        Map registermap = mdao.yxjlSelectAllOne(id);
System.out.println(registermap);
        map.put("pp", registermap);
        return "/page/recruit/interview/interview-register.html";
    }
    //点击面试登记
    @RequestMapping("Msinset")
    public String Msinset(EngageInterview e, EngageResume r){
        System.out.println(e.getResume_id()+"erwerwrwerwrwe");
        mdao.Msinset(e);
        edao.JlupdateInterview_amount(r);
        return "redirect:yxjlSelect";
    }

    //面试筛选
    @RequestMapping("sift_list")
    public String sift_list(Map map,
                            @RequestParam(defaultValue = "1",required = false) Integer startPage,
                            @RequestParam(defaultValue = "5",required = false) Integer PageSize){
        PageHelper.startPage(startPage, PageSize ); //使用分页插件
        List<Map> maps2 = mdao.interview_statusSelectAll();
        PageInfo pageInfo=new PageInfo(maps2, 5); //保存分页信息
        map.put("pageInfo", pageInfo);
        map.put("maps2", maps2);
        return "/page/recruit/interview/sift-list.html";
    }
    //筛选
    @RequestMapping("interview_sift")
    public String interview_sift(int id,Map map){
        Map registermap = mdao.yxjlSelectAllOne2(id);
        System.out.println(registermap);
        map.put("pp", registermap);
        return "/page/recruit/interview/interview-sift.html";
    }

    @RequestMapping("interview_sift_update")
public String interview_sift_update( EngageInterview g,int id){
        System.out.println(g);
        edao .update_jl_status(g.getCheck_status(),id);
        mdao.interview_sift_update(g);

        return "redirect:sift_list";
    }


    //删除简历表和面试表通过id
    @RequestMapping("jl_delete")
    public String jl_delete(int id){
edao.engage_resume_delete(id);
mdao.engage_interview_delete(id);
        return "redirect:sift_list";

    }

}
